package com.hmall.api.cart.fallback;

import com.hmall.api.cart.CartClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Collection;

/**
 * @author: wqy
 * @Date: 2025/09/04 11:33
 * @Description:
 */
@Slf4j
@Component
public class CartClientFallbackFactory implements FallbackFactory<CartClient> {

    @Override
    public CartClient create(Throwable cause) {
        return new CartClient() {
            /**
             * 降级策略
             */
            @Override
            public void removeByItemIds(Collection<Long> itemIds) {
                log.error("远程调用CartClient#removeByItemIds方法出现异常{}", cause.getMessage());
            }
        };
    }
}
